/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.yuhanginfo.modules.sys.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yuhanginfo.common.persistence.Page;
import com.yuhanginfo.common.service.CrudService;
import com.yuhanginfo.modules.sys.entity.Orders;
import com.yuhanginfo.modules.sys.dao.OrdersDao;

/**
 * 订单管理Service
 * @author yangs
 * @version 2017-09-18
 */
@Service
@Transactional(readOnly = true)
public class OrdersService extends CrudService<OrdersDao, Orders> {
    @Autowired
    private OrdersDao ordersDao;

	
	@Transactional(readOnly = false)
	public void save(Orders orders) {
		super.save(orders);
	}
	
	@Transactional(readOnly = false)
	public void delete(Orders orders) {
		super.delete(orders);
	}

	public Orders selectByCode(String code) {
		
		return ordersDao.selectByCode(code);
	}

	public Page<Orders> assignSaleMan(Page<Orders> page, Orders orders) {
		orders.setPage(page);
		page.setList(ordersDao.assignSaleMan(orders));
		return page;
	}
    
	@Transactional(readOnly = false)
	public void upSaleMan(Orders ord) {
		ordersDao.upSaleMan(ord);
	}

	public Page<Orders> handleOrderList(Page<Orders> page, Orders orders) {
		orders.setPage(page);
		page.setList(ordersDao.handleOrderList(orders));
		return page;
	}
	
	public Page<Orders> selectImportOrder(Page<Orders> page, Orders orders) {
		orders.setPage(page);
		page.setList(ordersDao.selectImportOrder(orders));
		return page;
	}
	
	@Transactional(readOnly = false)
	public void upStatus(Orders orders) {
		ordersDao.upStatus(orders);
	}
    
	@Transactional(readOnly = false)
	public void updateMoney(Orders orders) {
		ordersDao.updateMoney( orders);
		
	}

	public Page<Orders> abnormalOrderList(Page<Orders> page, Orders orders) {
		orders.setPage(page);
		page.setList(ordersDao.abnormalOrderList(orders));
		return page;
	}

	@Transactional(readOnly = false)
	public void updateHistoryState(Orders orders) {
		ordersDao.updateHistoryState(orders);
		
	}
    
	@Transactional(readOnly = false)
	public void removeHistoryState(Orders orders) {
		ordersDao.removeHistoryState(orders);
		
	}

	public String findMaxCode(String now) {
		
		return ordersDao.findMaxCode(now);
	}

	public List<Orders> selectByStoreCode(String code) {
		
		return ordersDao.selectByStoreCode(code);
	}
	
}